﻿
@{
    ViewBag.Title = "我的回复";
    Layout = "~/Views/Shared/_Member.cshtml";
}

<div class="row p10 bcolor oa pt20">
    <div class="layui-col-md12" id="dot_reply">
        <div class="row"></div>
    </div>

    <script id="dot_tmp_reply" type="text/x-dot-template">
        {{? it.length > 0 }}
        {{ for(var idx in it) { if(it[idx].ID) { var elm = it[idx]; }}
        {{? idx > 0 }}
        <hr />
        {{? }}

        {{? elm.Article }}
        <div class="row oa pt10 pt5">
            <div class="layui-col-md12">
                <p class="reply-title">回复文章：<a href="/Article/Info/{{= elm.Article.ID }}@(ViewBag.Suffix)" class="href" target="_blank">《{{= elm.Article.Title }}》</a></p>
            </div>
            <div class="layui-col-md12 pt5">
                <p class="reply-content">回复内容：{{= elm.Content }}</p>
            </div>
        </div>
        <div class="row pb10 oa pt5">
            {{ for(var idx2 in elm.Child) { if(elm.Child[idx2].ID) { var child = elm.Child[idx2]; }}
            <div class="layui-col-md11 pb5">
                <p class="reply-my-reply">
                    <a href="/Page/Index/{{= child.Member.Number }}@(ViewBag.Suffix)" class="href" target="_blank">{{= child.Member.Name }}</a> 回复我：<span class="to-me-reply">{{= child.Content }}</span> <a href="javascript:void(0)" class="href" onclick="javascript: { reply.submit({{= elm.ArticleID }},{{= child.ID }}); }">快速回复</a>
                </p>
            </div>
            {{ } } }}
        </div>
        {{?? }}
        <div class="row oa pt10">
            <div class="layui-col-md12">
                <p class="reply-title">回复 <a href="/Page/Index/{{= elm.Parent.Member.Number }}@(ViewBag.Suffix)" class="href" target="_blank">{{= elm.Parent.Member.Name }}</a>：{{= elm.Parent.Content }}</p>
            </div>
            <div class="layui-col-md12 pt5">
                <p class="reply-content">回复内容：{{= elm.Content }}</p>
            </div>
        </div>
        <div class="row pb10 oa pt5">
            {{ for(var idx2 in elm.Child) { if(elm.Child[idx2].ID) { var child = elm.Child[idx2]; }}
            <div class="layui-col-md11 pb5">
                <p class="reply-my-reply">
                    <a href="/Page/Index/{{= child.Member.Number }}@(ViewBag.Suffix)" class="href" target="_blank">{{= child.Member.Name }}</a> 回复我：<span class="to-me-reply">{{= child.Content }}</span> <a href="javascript:void(0)" class="href" onclick="javascript: { reply.submit({{= elm.ArticleID }},{{= child.ID }}); }">快速回复</a>
                </p>
            </div>
            {{ } } }}
        </div>
        {{? }}

        {{ } } }}
        {{?? }}
        <div class="row p20p10 bcolor oa">{{= noDataTitle }}</div>
        {{? }}
    </script>

    <div id="page" class="row p20p10 oa tcenter"></div>
</div>

<script>
    var reply = new Reply();
    $(function () {
        reply.getData();
    });


    ; function Reply() {
        this.paras = {
            page: 1,
            rows: 10,
            count: 0
        };
        this.option = {
            elem: 'page'
        };
        this.getData = function (isLoad, next) {
            if (isLoad) { this.paras.page = next; }
            else { this.paras.page = 1; }
            var this_obj = this;
            $.post('/member/GetMemberReplyListResult', this_obj.paras, function (result) {
                this_obj.paras.count = result.count;
                if (!isLoad) { this_obj.setPage(); }
                var dotTmp = doT.template($("#dot_tmp_reply").text());
                $("#dot_reply").html(dotTmp(result.data));
            });
        };
        this.setPage = function () {
            var this_obj = this;
            layui.laypage.render({
                elem: this_obj.option.elem,
                count: this_obj.paras.count,
                limit: this_obj.paras.rows,
                theme: '#3499DB',
                layout: ['count', 'prev', 'page', 'next'],
                jump: function (obj, first) {
                    if (!first) {
                        var index = obj.curr;
                        this_obj.getData(true, index);
                    }
                }
            });
        };
        this.submit = function (articleId, replyId) {
            layer.prompt({ title: '请输入回复内容', formType: 2 }, function (content, index) {
                layer.close(index);
                var paras = { articleId: articleId, replyId: replyId, content: content };
                $.post('/reply/EditReplyResult', paras, function (result) {
                    reply.getData();
                });
            });
        };
    };


</script>